<?php
/**
 * PrynLib
 * @copyright 2007-2009 Prynel
 * @author Olivier ROGER <roger.olivier@gmail.com>
 * @category libPrynel
 * @package Log
 * @version $Revision: 80 $
 */

/**
 * Sends the given data to the FirePHP Firefox Extension.
 * The data can be displayed in the Firebug Console or in the
 * "Server" request tab.
 * 
 * @see http://www.firephp.org/Wiki/Reference/Fb
 * @param mixed $Object
 * @return true
 * @throws Exception
 * @category libPrynel
 * @package Log
 */
function fb()
{
  $instance = Log_FirePHP::getInstance(true);
  
  $args = func_get_args();
  return call_user_func_array(array($instance,'fb'),$args);
}


class Log_FB
{
  /**
   * Enable and disable logging to Firebug
   * 
   * @see Log_FirePHP->setEnabled()
   * @param boolean $Enabled TRUE to enable, FALSE to disable
   * @return void
   */
  public static function setEnabled($Enabled) {
    $instance = Log_FirePHP::getInstance(true);
    $instance->setEnabled($Enabled);
  }
  
  /**
   * Check if logging is enabled
   * 
   * @see Log_FirePHP->getEnabled()
   * @return boolean TRUE if enabled
   */
  public static function getEnabled() {
    $instance = Log_FirePHP::getInstance(true);
    return $instance->getEnabled();
  }  
  
  /**
   * Specify a filter to be used when encoding an object
   * 
   * Filters are used to exclude object members.
   * 
   * @see Log_FirePHP->setObjectFilter()
   * @param string $Class The class name of the object
   * @param array $Filter An array or members to exclude
   * @return void
   */
  public static function setObjectFilter($Class, $Filter) {
    $instance = Log_FirePHP::getInstance(true);
    $instance->setObjectFilter($Class, $Filter);
  }
  
  /**
   * Set some options for the library
   * 
   * @see Log_FirePHP->setOptions()
   * @param array $Options The options to be set
   * @return void
   */
  public static function setOptions($Options) {
    $instance = Log_FirePHP::getInstance(true);
    $instance->setOptions($Options);
  }

  /**
   * Log object to firebug
   * 
   * @see http://www.Log_FirePHP.org/Wiki/Reference/Fb
   * @param mixed $Object
   * @return true
   * @throws Exception
   */
  public static function send()
  {
    $instance = Log_FirePHP::getInstance(true);
    $args = func_get_args();
    return call_user_func_array(array($instance,'fb'),$args);
  }

  /**
   * Start a group for following messages
   *
   * @param string $Name
   * @return true
   * @throws Exception
   */
  public static function group($Name) {
    return self::send(null, $Name, Log_FirePHP::GROUP_START);
  }
  
  /**
   * Ends a group you have started before
   *
   * @return true
   * @throws Exception
   */
  public static function groupEnd() {
    return self::send(null, null, Log_FirePHP::GROUP_END);
  }

  /**
   * Log object with label to firebug console
   *
   * @see Log_FirePHP::LOG
   * @param mixes $Object
   * @param string $Label
   * @return true
   * @throws Exception
   */
  public static function log($Object, $Label=null) {
    return self::send($Object, $Label, Log_FirePHP::LOG);
  } 

  /**
   * Log object with label to firebug console
   *
   * @see Log_FirePHP::INFO
   * @param mixes $Object
   * @param string $Label
   * @return true
   * @throws Exception
   */
  public static function info($Object, $Label=null) {
    return self::send($Object, $Label, Log_FirePHP::INFO);
  } 

  /**
   * Log object with label to firebug console
   *
   * @see Log_FirePHP::WARN
   * @param mixes $Object
   * @param string $Label
   * @return true
   * @throws Exception
   */
  public static function warn($Object, $Label=null) {
    return self::send($Object, $Label, Log_FirePHP::WARN);
  } 

  /**
   * Log object with label to firebug console
   *
   * @see Log_FirePHP::ERROR
   * @param mixes $Object
   * @param string $Label
   * @return true
   * @throws Exception
   */
  public static function error($Object, $Label=null) {
    return self::send($Object, $Label, Log_FirePHP::ERROR);
  } 

  /**
   * Dumps key and variable to firebug server panel
   *
   * @see Log_FirePHP::DUMP
   * @param string $Key
   * @param mixed $Variable
   * @return true
   * @throws Exception
   */
  public static function dump($Key, $Variable) {
    return self::send($Variable, $Key, Log_FirePHP::DUMP);
  } 

  /**
   * Log a trace in the firebug console
   *
   * @see Log_FirePHP::TRACE
   * @param string $Label
   * @return true
   * @throws Exception
   */
  public static function trace($Label) {
    return self::send($Label, Log_FirePHP::TRACE);
  } 

  /**
   * Log a table in the firebug console
   *
   * @see Log_FirePHP::TABLE
   * @param string $Label
   * @param string $Table
   * @return true
   * @throws Exception
   */
  public static function table($Label, $Table) {
    return self::send($Table, $Label, Log_FirePHP::TABLE);
  } 

}


